<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>Thenable (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">Thenable</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Provides a more strict interface for Thenables in terms of
<a href="http://promisesaplus.com">http://promisesaplus.com</a> for interop with .


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="goog.Promise">Also See:</a></li>
            <li><a href="local_closure_goog_promise_thenable.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/promise/thenable.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td>goog.Thenable</td><td></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
      <tr><td><span class="type"><a href="interface_goog_result_Result.html">goog.result.Result</a></span></td><td>goog.Thenable</td></tr>
        <tr><td><span class="type"><a href="interface_goog_result_DependentResult.html">goog.result.DependentResult</a></span></td><td><span class="type"><a href="interface_goog_result_Result.html">goog.result.Result</a></span></td></tr>
  </table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.Thenable(<span></span>)
  </div>



<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="interface_goog_Thenable.html">
              goog.Thenable
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Thenable.prototype.then"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">then<span class="args">(<span class="arg">opt_onFulfilled</span>,&nbsp;<span class="arg">opt_onRejected</span>,&nbsp;<span class="arg">opt_context</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type">RESULT</span>&gt;
      </div>


     <div class="entryOverview">
       Adds callbacks that will operate on the result of the Thenable, returning a
new child Promise.

If the Thenable is fulfilled, the <code> onFulfilled</code> callback will be
invoked with the fulfillment value as argument, and the child Promise will
be fulfilled with the return value of the callback. If the callback throws
an exception, the child Promise will be rejected with the thrown value
instead.

If the Thenable is rejected, the <code> onRejected</code> callback will be invoked
with the rejection reason as argument, and the child Promise will be rejected
with the return value of the callback or thrown value.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_onFulfilled</span>
        : <span>?</span>(<span class="type">function(this:THIS, TYPE):
               (RESULT</span><span>&nbsp;|&nbsp;</span><span class="type">IThenable</span>.&lt;<span class="type">RESULT</span>&gt;<span>&nbsp;|&nbsp;</span><span class="type">Thenable))=</span>
        <div class="entryOverview">A
    function that will be invoked with the fulfillment value if the Promise
    is fullfilled.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_onRejected</span>
        : <span>?</span>(<span class="type">function(*): *)=</span>
        <div class="entryOverview">A function that will be invoked
    with the rejection reason if the Promise is rejected.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_context</span>
        : <span class="type">THIS=</span>
        <div class="entryOverview">An optional context object that will be the
    execution context for the callbacks. By default, functions are executed
    with the default this.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type">RESULT</span>&gt;&nbsp;
            A new Promise that will receive the result
    of the fulfillment or rejection callback.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_promise_thenable.js.source.html#line57">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>














<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Thenable.addImplementation"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.Thenable.</span><span class="entryName">addImplementation<span class="args">(<span class="arg">ctor</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Marks a given class (constructor) as an implementation of Thenable, so
that we can query that fact at runtime. The class must have already
implemented the interface.
Exports a 'then' method on the constructor prototype, so that the objects
also implement the extern  interface for interop with
other Promise implementations.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">ctor</span>
        : <span class="type">function(new:goog.Thenable,...[?]</span>)
        <div class="entryOverview">The class constructor. The
    corresponding class must have already implemented the interface.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_promise_thenable.js.source.html#line82">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.Thenable.isImplementedBy"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.Thenable.</span><span class="entryName">isImplementedBy<span class="args">(<span class="arg">object</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">object</span>
        : <span class="type">*</span>
        <div class="entryOverview"><span class='nodesc'>No description.</span></div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether a given instance implements <code> goog.Thenable</code>.
    The class/superclass of the instance must call <code> addImplementation</code>.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_promise_thenable.js.source.html#line98">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.Thenable.IMPLEMENTED_BY_PROP"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.Thenable.</span><span class="entryName">IMPLEMENTED_BY_PROP</span>
        : 
     </div>


     <div class="entryOverview">
       An expando property to indicate that an object implements
<code> goog.Thenable</code>.

.


     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_promise_thenable.js.source.html#line69">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package Thenable</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="Thenable"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
